import { AttrType } from "../../attr/AttrType";
import { EventId } from "../../event/EventId";
import EventMgr from "../../event/EventMgr";
import { BattleRole } from "../../role/BattleRole";
import { ITriggerResult, TreateResult } from "../../trigger/const/ITriggerResult";
import { EffectBase } from "../EffectBase";

/**
 * 治疗效果
 */
export class TreatEffect extends EffectBase {

    excute(args: { caster: BattleRole; target: BattleRole; results: ITriggerResult[]; }): void {
        let attrVal = args.target.attrMgr.getAttr(this.params.attrType);
        let val = attrVal * this.params.value >> 0;
        args.target.attrMgr.updateAttr(AttrType.hp, val)
        let result: TreateResult = {
            resultType: "treate",
            target: args.target,
            treateNum: val
        }
        args.results.push(result);
        EventMgr.ins.event(EventId.TRIGGER_RESULT, result)
    }

    get params(): { attrType: AttrType, value: number } {
        return this._params
    }

}